#pragma once

#import <Availability.h>

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

#import "AFNetworking.h"

#import "MRFilter.h"
#import "MRDatabase.h"
#import "FSServer.h"
#import "FSUser.h"
#import "FSRecord.h"
#import "FSSport.h"
#import "FSGroup.h"
#import "FSDevice.h"
#import "FSModel.h"
#import "FSRegion.h"

#import "SportVoice.h"
#import "StepCounter.h"

#import "BLEManager.h"
#import "BLEDevice.h"
#import "BLETreadmill.h"
#import "BLEBicycle.h"
#import "BLEHealth.h"

#define FS_VERSION			@"2.4"		//当前FSFoundation的版本

#define M_POUND				2.20462f
#define M_FOOT				3.28084f
#define	M_INCL				1.609344f
#define	M_INCL_K			1609.344f

#define HIBYTE(w)           (Byte)((w) >> 8)
#define LOBYTE(w)           (Byte)((w) & 0x00ff)

#define HIWORD(l)           (uint)((l) >> 16)
#define LOWORD(l)           (uint)((l) & 0xffff)

#define MAKELONG(a, b)      (uint)((uint)(a) | ((uint)(b) << 16))
#define MAKEWORD(a, b)      (uint)((uint)(a) | ((uint)(b) << 8))
#define MAKEDWORD(a,b,c,d)  (uint)(MAKELONG(MAKEWORD(a, b), MAKEWORD(c, d)))

#define	WORDBYTE(d)			LOBYTE(d), HIBYTE(d)
#define	DWORDBYTE(d)		LOBYTE(LOWORD(d)), HIBYTE(LOWORD(d)), LOBYTE(HIWORD(d)), HIBYTE(HIWORD(d))

#define TICKCOUNT			CFAbsoluteTimeGetCurrent()

#if (DEBUG == 1)
#define DLog(s, ...)		NSLog(@"<%@:(%d)> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__])
#else
#define DLog(s, ...)
#endif

#define APPLANGUAGE			@"appLanguage"
CG_INLINE NSBundle * BundleLanguage()
{
	NSString *lang = [[NSUserDefaults standardUserDefaults] objectForKey:APPLANGUAGE];
	if (lang)
	{
		NSString *file = [[NSBundle mainBundle] pathForResource:lang ofType:@"lproj"];
		if ([[NSFileManager defaultManager] fileExistsAtPath:file])
		{
			return [NSBundle bundleWithPath:file];
		}
	}
	return [NSBundle mainBundle];
}

//2.0 新增加的宏
#define L(key)				([BundleLanguage() localizedStringForKey:(key) value:nil table:nil])	//根据当前语言设置，获取指定标识的内容
#define ARY(key)			([L(key) componentsSeparatedByString:@","])								//获取指定标识内容，并按逗号分离成数组
#define UNIT(key)			([L(key) componentsSeparatedByString:@","][[FSUser imperial]])			//根据当前用户英制单位设置，获取对应标识下对应单位的内容

//简化宏操作
#define F(format, ...)		([NSString stringWithFormat:(format), ##__VA_ARGS__])		//简化的字符串格式合成
#define IMG(file)			([UIImage imageNamed:(file)])
